home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
UTILITIE
/
CPU_MEMO
/
3468.ZIP
/
POPUP.ZIP
/
SCREENIO.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-06-30
|
4KB
|
170 lines
;*****************************************************************************
;* Module SCREENIO.ASM - Contains simple functions for writing directly to *
;* a monochrome, cga, ega, vga etc display. For use with "windows" module. *
;*****************************************************************************
include CLINK.INC
.DATA
extrn _DisplaySegment:word
extrn _DisplayStatus:word
.CODE
;=================================================================
;
; void WriteScreen(row,col,buffer,words)
; int row; row coordinate to print to
; int col; col coordinate to print to
; char *buffer; address of buffer to print to screen
; int words; number of char/attrib pairs to put
;
;=================================================================
PUBLIC _WriteScreen
STARTPROC _WriteScreen
DEFARGS row, WORD, col, WORD, buffer, PTR, words, WORD
push es
push ds
push si
push di
mov dx,_DisplaySegment
mov es,dx ; screen address in ES
MOVARG ax,row
mov cl,80 ; get ready to multiply for line offset
mul cl
mov cx,2 ; get ready to multiply char & attrib
mul cx
push ax
MOVARG ax,col
mov cl,2
mul cl
mov cx,ax
pop ax
add ax,cx
mov di,ax ; screen offset in DI
mov dx,_DisplayStatus
LDPTR ds, si, buffer
MOVARG cx, words
nxtchr:
cmp cx,0
jbe pdone ; go if byte count <= 0
mov bx,[si] ;char and attrib in BX
pwait_lo1:
in al,dx
test al,1
jnz pwait_lo1
pwait_hi1:
in al,dx
test al,1
jz pwait_hi1
pputit:
mov es:[di],bx ;
inc si
inc si
inc di
inc di
dec cx
jmp nxtchr
pdone:
pop di
pop si
pop ds
pop es
RETPROC
_WriteScreen endp
;=================================================================
;
; void ReadScreen(row,col,buffer,words)
; int row; row coordinate to get from
; int col; col coordinate to get from
; char *buffer; address of buffer to put screen info into
; int words; number of char/attrib pairs to get
;
;=================================================================
PUBLIC _ReadScreen
STARTPROC _ReadScreen
DEFARGS row, WORD, col, WORD, buffer, PTR, words, WORD
push es
push ds
push si
push di
mov dx,_DisplaySegment
mov es,dx
MOVARG ax,row
mov cl,80 ; get ready to multiply for line offset
mul cl
mov cx,2 ; get ready to multiply char & attrib
mul cx
push ax
MOVARG ax,col
mov cl,2
mul cl
mov cx,ax
pop ax
add ax,cx
mov si,ax ; screen offset in SI
mov dx,_DisplayStatus
LDPTR ds, di, buffer
MOVARG cx, words
gwait_lo1:
in al,dx
test al,1
jnz gwait_lo1
gwait_hi1:
in al,dx
test al,1
jz gwait_hi1
gputit:
mov bx,es:[si] ; char from screen to BL
inc si ; point to attrib byte
inc si
mov [di],bx ;put char+attrib in buffer
inc di ;/_____ increment
inc di ;\ screen pointer
dec cx ; 1 less word to move
cmp cx,0
jnz gwait_lo1
pop di
pop si
pop ds
pop es
RETPROC
_ReadScreen endp
END